<template>
  <!-- 广告页 -->
  <div class="content">
    <!-- 右上角离开按钮 -->
    <div class="leave" @tap="clickGoHome">{{second}} 跳过</div>
    <!-- 广告图片 -->
    <img src="static/img/ad.png">
    <img  class="ad_bottom" src="static/img/ad_bottom_750_1334.png" >
  </div>
</template>
<script>
  import storage from '@/utils/localstorage'
  import {getPhotos} from '@/nodeApi/other'
  export default {
    data() {
      return {
        img: '',
        second: 3,
      }
    },
    created() {
      let that = this
      let width = document.documentElement.clientWidth

      //console.log(width)
     /*  getPhotos({used:2}).then(res=>{
        this.img = process.env.PATH_INDEX_PIC+res.data.photo.path
      }) */
      window.t1 = setInterval(this.goHome,1000); 
      
      /* switch (width) {
        case 240:
          this.img = 'static/img/ad/480.png'
          break;
        case 360:
          this.img = 'static/img/ad/720.png'
          break;
        case 504:
          this.img = 'static/img/ad/1008.png'
          break;
        case 320:
          this.img = 'static/img/ad/iphone5.png'
          break;
        case 375:
          this.img = 'static/img/ad/iphone6.png'
          break;
        case 621:
          this.img = 'static/img/ad/iPhone6sp.png'
          break;
        case 562.5:
          this.img = 'static/img/ad/iPhonex.png'
          break;
       
        case 384:
          this.img = 'static/img/ad/ipad/768-1024.png'
          break;
        case 748:
          this.img = 'static/img/ad/ipad/1496-2048.png'
          break;
    
        default :
          this.img = 'static/img/ad/iphone4.png'
          break;
        //console.log(this.img)
      } */
    },
    mounted() {
    },
    //注意销毁掉监听，不然报错
    destroyed () {
      clearTimeout(window.t1)
    },
    components: {},
    methods: {
      goHome() {
        this.second = this.second - 1
        if(this.second == 0){
          this.clickGoHome()
        }
      },
      clickGoHome(){
        if(localStorage.confirmClause){
          this.$router.push({
            name: "home", 
            params: {
              adHas: true,
            }    
          })
        }else{
          this.$router.push({
            name: "confirmClause",
            params: {
              adHas: true
            }    
          })
        }
      }  
    }
  }

</script>

<style scoped>
.content{
  width: 100%;
  height: 100%;
  background: #fff;
}
.content img{
  width:100%;
  /* height: 100%; */
}
.leave{
  width:50px;
  height:25px;
  background: red;
  position: absolute;
  right:10px;
  top:6%;
  border-radius: 25px;
  font-size:12px;
  background: black;
  opacity: 0.5;
  color:#fff;
  text-align: center;
  line-height: 25px;
}
.ad_bottom{
  width: 100%;
  position: absolute;
  bottom: 0px;
  z-index: 99;
}
</style>

